#ifndef __DSTH_REACTOR_THREAD_H__
#define __DSTH_REACTOR_THREAD_H__

#include "BaseThread.h"
#include "EventLoop.h"
#ifdef IS_WINDOWS
  #include "Event.h"
#else
  #include "Condition_POSIX.h"
#endif

namespace dsth {
class EventLoop;
class ReactorThread {
public:
    ReactorThread();
    ~ReactorThread();
    EventLoop* Run();
    EventLoop* GetEventLoop() { return &loop_; }
    void Join();
private:
    // Can't invoke copy constructor or assignment operator
    ReactorThread(const ReactorThread&);
    void operator=(const ReactorThread&);

    void Loop(const char* thread_name);

    BaseThread thread_;
#ifdef IS_WINDOWS
    Event event_;
#else
    Mutex mutex_;
    Condition event_;
#endif
    EventLoop* loop_ptr_;
    EventLoop loop_;
    bool started_;
};

} // namespace
#endif // __DSTH_REACTOR_THREAD_H__
